Example: .NET Expression
The dataset will be modified to include the added field and the values as specified in the expression.
Example 1: Writing an expression using the System.Math namespace
Initial dataset:
Configuration:
Output field name: NewField
Output field type: Double
Expression:
C#:
Integer1 + 10 + Math.Round(Double1), or
VB.NET:
Integer1 + 10 + Math.Round(Double1)
Verify script: No errors are shown when verifying this expression.
Resulting dataset:
NOTE: The null value in the string field, String1, did not influence the output value for row 7 since String1 was not used in the expression.
Example 2: Data type conversion
Initial dataset:
Configuration:
Output field name: NewField
Output field type: Integer
Expression:
C#:
(int) Math.Floor(Double1)
Note: The Math.Floor(double) .NET method returns a "double" type, so the output value needs to be casted to "int"
VB.NET:
Math.Floor(Double1)
Verify script: No errors are shown when verifying this expression.
Resulting dataset:
Note: The null values for Integer1 and String1 does not influence the values of NewField or make them null, because the fields were not used in the expression.
Example 3: Adding strings
Initial dataset:
Configuration:
Output field name: NewField
Output field type: String
Expression:
C#:
String1 + "_" + Integer1.ToString()
VB.NET:
String1 + "_" + Integer1.ToString()
Verify script: No errors are shown when verifying this expression.
Resulting dataset:
Example 4: Timestamp manipulation
Initial dataset:
Configuration:
Output field name: NewField
Output field type: DateTime
Expression:
C#:
Timestamp1.AddMinutes(-20)
VB.NET:
Timestamp1.AddMinutes(-20)
Note: Adding -20 minutes to Timestamp1 moves the times of the new field back 20 minutes in time.
Verify script: No errors are shown when verifying this expression.
Resulting dataset:
Related topics: